package com.hh.flow.mapper;

import com.hh.flow.domain.FlowNode;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

import static com.hh.flow.domain.tables.FlowDefinitionTableDef.flow_definition;
import static com.hh.flow.domain.tables.FlowNodeTableDef.flow_node;

/**
 * 流程结点Mapper接口
 *
 * @author hh
 * @date 2023-03-29
 */
public interface FlowNodeMapper extends BaseMapper<FlowNode> {
    default List<FlowNode> queryNewVersionFlowNodeByFlowCode(String flowCode)
    {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select(flow_node.id,
                        flow_node.definition_id,
                        flow_node.node_name,
                        flow_node.node_code,
                        flow_node.update_time,
                        flow_node.node_type,
                        flow_definition.version)
                .from(flow_node).as("a")
                .innerJoin(flow_definition).as("b")
                .on(flow_definition.flow_code.eq(flowCode)
                        .and(flow_node.definition_id.eq(flow_definition.id))
                        .and(flow_definition.is_publish.eq(1L)));
        return selectListByQuery(queryWrapper);
    }

}
